<?php

class quoteComponents extends sfComponents
{
  public function executeRandomQuotes($number)
  {
    $this->quotes = array();

    if(!is_int($number)) $number = 5;
    $count = QuoteQuery::create()->count();

    $quotes = array();
    $rand = array();
    for ($i=0; $i < $number ; $i++)
    {
      $gen_rand = rand(1, $count);
      while(in_array($gen_rand, $rand))
      {
        $gen_rand = rand(1, $count);
      }

      $this->quotes[] = QuoteQuery::create()
      ->setOffset($gen_rand)
      ->findOne();
    }
  }
}
